package com.villaday.idf.adapter2;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.base.OnAdapterCallbackListener;
import com.villaday.idf.custom.foldtext.FoldTextView;
import com.villaday.idf.model.MaterialRecommendEntity;
import com.villaday.idf.model.RefreshtokenEntity;
import com.villaday.idf.model2.Hot_houses;
import com.villaday.idf.util.PhoneUtil;
import com.villaday.idf.util.SharedPreferencesUtil;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import byc.imagewatcher.MessagePicturesLayout;

/**
 * 首页动态列表
 */

public class HotHouseAdapter extends AbsRecyclerViewAdapter<Hot_houses.BodyEntity.ListEntity> {
    private OnAdapterCallbackListener onAdapterCallbackListener;
    private View.OnClickListener onClickListener;
    private MessagePicturesLayout.Callback mCallback;
    private  String roleType;

    public HotHouseAdapter(Context context, OnAdapterCallbackListener onAdapterCallbackListener, View.OnClickListener onClickListener) {
        super(context, R.layout.item_home2v_type3, /*R.layout.item_dynamic_1, R.layout.item_dynamic_2,*/ R.layout.item_page_loading,
                R.layout.item_page_bottom);
        this.onAdapterCallbackListener = onAdapterCallbackListener;
        this.onClickListener = onClickListener;

        RefreshtokenEntity.BodyBean roleInfo =
                SharedPreferencesUtil.getRoleInfo(context);
        roleType = roleInfo.getMember().getType();


    }
    public void setRoleType(){
        RefreshtokenEntity.BodyBean roleInfo =
                SharedPreferencesUtil.getRoleInfo(context);
        roleType = roleInfo.getMember().getType();
    }
    @Override
    public int getItemType(Hot_houses.BodyEntity.ListEntity d) {
        return d.getMyType();
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, Hot_houses.BodyEntity.ListEntity d, int position) {
        switch (d.getMyType()) {
            case 0: {//
                holder.bindSimpleDraweeView(R.id.sdv,d.getImageUrl())
                .bindTextView(R.id.tv_title,d.getName())
                        .bindTextViewWithHtml(R.id.tv_priceFuHao,"&yen;")

                        .bindTextView(R.id.tv_zhu,d.getDesc())
                        .bindTextView(R.id.tv_price,d.getCurrentPriceValue())
                        .bindTextView(R.id.tv_Zhuan,"立返￥"+d.getBrokerAgeAmountValue())
                        .setViewVisible(R.id.ll_Zhuan, "0".equals(roleType) ? View.GONE : View.VISIBLE);







                PhoneUtil.setExternalFont(context, (TextView) holder.getView(R.id.tv_priceFuHao),true);
                PhoneUtil.setExternalFont(context, (TextView) holder.getView(R.id.tv_price),true);
                PhoneUtil.setExternalFont(context, (TextView) holder.getView(R.id.tv_qi),false);
                PhoneUtil.setExternalFont(context, (TextView) holder.getView(R.id.tv_Zhuan),false);



            }
            break;

            case 1: {
                onAdapterCallbackListener.onCallback();
            }
            break;


        }
    }
}
